/**
 * 
 */
package com.antilia.infomaresme.data.dao.hibernate;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

import com.antilia.infomaresme.data.dao.interfaces.IUsersDao;
import com.antilia.infomaresme.data.dataobjects.User;

/**
 * @author Ernesto
 *
 */
public class UsersDao extends AbstractDaoHibernateImpl<User> implements IUsersDao {

	/**
	 * @param domainClass
	 */
	public UsersDao() {
		super(User.class);
	}
	
	public User loadById(String userId) {
		Criteria criteria = getSession().get().createCriteria(User.class);
		criteria.add(Restrictions.eq("userId", userId));
		@SuppressWarnings("unchecked")
		List<User> users = (List<User>)criteria.list();
		return users.size()>0?users.get(0): null;
	}

}
